package com.example.javaeekeshe.utils;

import org.springframework.stereotype.Repository;

/**
 * byte转字符串
 * @author 化粪池堵塞的凶手
 */
@Repository
public class CharUtils {
    private final static char[] HEX = "qpwoeiruty293847".toCharArray();

    public static String bytes2Hex(byte[] bys) {
        char[] chs = new char[bys.length * 2];
        for(int i = 0, offset = 0; i < bys.length; i++) {
            chs[offset++] = HEX[bys[i] >> 4 & 0xf];
            chs[offset++] = HEX[bys[i] & 0xf];
        }
        return new String(chs);
    }
}
